package com.ruoyi.ai.factory;

import com.ruoyi.ai.domain.vo.WxChatVo;
import com.ruoyi.ai.domain.vo.WxModelConfigVo;
import com.ruoyi.ai.service.IWxModelConfigService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public abstract class ModelChatTemplate implements ModelChatService, InitializingBean {
    private IWxModelConfigService wxModelConfigService;

    public static final String OVER_FLAG = "THIS_CHAT_OVER";
    @Autowired
    public final void setWxModelConfigService(IWxModelConfigService wxModelConfigService) {
        this.wxModelConfigService = wxModelConfigService;
    }
    private String mfg;
    public ModelChatTemplate(String mfg){
        this.mfg = mfg;
    }

    @Override
    public abstract String chatStream(List<WxChatVo> chatVoList, Long userId);

    public WxModelConfigVo getConfig() {
        //TODO 改成走缓存
        return wxModelConfigService.queryByMfg(mfg);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        ModelChatStrategyFactory.register(mfg,this);
    }
}
